package day2;

import java.util.Scanner;

import org.junit.Test;

public class SwitchDemo {
	@Test
	public void test1() {
		int type = 1;
		switch(type) {
		case 1:
			System.out.println("1");
			break;
		case 2:
			System.out.println("2");
			break;
		case 3:
		case 4:
			System.out.println("3");
		default:
			System.out.println("defalut");
			break;
		}
	}
	
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		switch(month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println("31天");
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			System.out.println("30天");
			break;
		case 2:
			System.out.println("请输入年份：");
			int year = scanner.nextInt();
			if ((year % 4 == 0 && year % 100 !=0) || year % 400 == 0) {
				System.out.println("28天");
			} else {
				System.out.println("29天");
			}
			break;
		default:
			System.out.println("请输入正确月份");
			break;
		}
	}
	
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入成绩");
		int score = scanner.nextInt();// Alt+Shift+L
		//while(true) {
		if (score > 100 || score < 0) {
			System.out.println("请再次输入成绩");
//			return;
		}
			
			//score = scanner.nextInt();
		//}
		switch(score / 10) {
		case 10:
		case 9:
			System.out.println("优秀");
			break;
		case 8:
			System.out.println("良好");
			break;
		case 7:
			System.out.println("一般");
			break;
		case 6:
			System.out.println("合格");
			break;
		default:
			System.out.println("不合格");
			break;
		}
		
	}
}
